package universe;

import junit.framework.TestCase;

public class BlockTest extends TestCase {

	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testBlock() {
		Block a = new Block(Utils.getBlockA());
		Block b = new Block(Utils.getBlockB());
		Block c = new Block(Utils.getBlockC());
		Block d = new Block(Utils.getBlockD());
		Block e = new Block(Utils.getBlockE());
		Block f = new Block(Utils.getBlockF());
		Block g = new Block(Utils.getBlockG());
		
		assertTrue(a instanceof Block);
		assertTrue(b instanceof Block);
		assertTrue(c instanceof Block);
		assertTrue(d instanceof Block);
		assertTrue(e instanceof Block);
		assertTrue(f instanceof Block);
		assertTrue(g instanceof Block);
	}

	public void testRotate() {
		Block b = new Block(Utils.getBlockA());
		for(int i = 0; i<10 ; i++){
			int posPrecedente = b.getCurrentPosition();
			b.rotate();
			assertTrue(b.getCurrentPosition() < 4 && b.getCurrentPosition() >=0);
			assertTrue(b.getCurrentPosition() == (posPrecedente+1)%4);
		}
	}

	public void testGetMatrix() {
		Block b = Block.getRandomBlock();
		int[][] matrix = b.getMatrix();
		assertTrue(matrix instanceof int[][]);
	}

	public void testGetCurrentPosition() {
		Block b = Block.getRandomBlock();
		assertTrue(b.getCurrentPosition() >= 0 && b.getCurrentPosition() < 4);
	}

	public void testRandomBlock() {
		Block b = Block.getRandomBlock();
		assertTrue(b instanceof Block);
	}

}
